import _ from 'lodash'

let config = (function () {
  let ENV = 'TEST'; // 环境配置 必填项。【DEMO,DEV,TEST,PROD 】 【本地例子，开发，测试，正式】
  let version = 'TEST20190221v1.0';
  let projectName = '_lj_merchant_'; // 必填项 项目的名字，用来区分多个项目，尤其是在cookie
  let PARAM = {
    'DEMO': {
      API_BASE_URL: ''
    },
    'DEV': {
      BASE_URL: 'http://lj.swao.cn/',
      RES_UPLOAD_BASE_URL: 'https://s.swao.cn/',
      API_BASE_URL: 'http://192.168.1.101:9050/'//康文根电脑ip
    },
    'TEST': {
      BASE_URL: 'http://lj.swao.cn/',
      //API_BASE_URL: 'http://47.96.23.31:8080/',
      API_BASE_URL: 'http://ljapi.swao.cn/',
      RES_UPLOAD_BASE_URL: 'http://s.swao.cn/'
    },
    'PROD': {
      BASE_URL: 'http://tv.swao.cn/',
      API_BASE_URL: 'http://api.pointshow.net/',
      RES_UPLOAD_BASE_URL: 'http://s.swao.cn/'
    }
  };

  let URLS = {};

  let cookieName = {
    user: projectName + 'user',
    token: projectName + 'token', // 登录存储
    mobile: projectName + 'mobile', // 手机号存储
    role: projectName + '_role_', // 角色
    pageinfo: projectName + '_page_info_',
    channel: projectName + 'channel',
    program: projectName + 'program',
    template: projectName + 'template',
    storageService: projectName + 'storageService' // 存储服务
  };

  let company = {
    name: '',
    phone: '',
    mobile: '',
    email: '',
    address: ''
  };

  let apiName = { // 接口名字
    login: 'SAASLogin/merchant',//登录接口
    updatePwd: 'merchant/employee/password/modify',//修改密码
    upload: '/qiniu/uptokenV2', // 上传接口
    uploadToken: 'qiniu/uptokenV2',// 七牛token获取

    getStoreListUrl: 'classify/getTree', //获取门店列表
    findStoreByIdUrl: 'terminal/search',//通过门店id查询门店信息

    getPosterModuleListUrl: 'posterTemplate/search',//获取海报模板
    findPosterModuleByIdUrl: 'posterTemplate/read',//通过id海报模板

    getProgramListUrl: 'program/search',//获取节目列表
    findProgramByIdUrl: 'program/v2/read',//通过id查询节目
    createProgram: 'program/v2/create',//创建节目
    updateProgram: 'program/v2/update',
    findProgramScreen: 'terminal/find-publish-channel-on-program',

    findPosterById: 'poster/read',//通过id海报
    updatePoster: 'poster/update',//更新海报
    createPoster: 'poster/create',//创建海报

    getResourceList: 'resource/search',//资源图库列表
    updatePassword: 'merchant/employee/password/modify',//资源图库列表
  };

  let page_info = {
    data: {
      logo: 'http://s.swao.cn/logo/longjing_logo.png',
      headImg: '',
      company: {}
    },
    set: function (pageInfo) {
      this.data = _.defaultsDeep(pageInfo, this.data);
    },
    get: function () {
      return this.data;
    }
  };

  let dom = {
    id: {
      app: 'app',
      custom: 'custom_page',
      customfull: 'customfull_page',
      tpl: '_tpl_hidden'
    }
  };

  return {
    pageName: '',
    apiName: apiName,
    ENV: ENV,
    PARAM: PARAM[ENV],
    URLS: URLS,
    cookieName: cookieName,
    company: company,
    projectName: projectName,
    demoData: {},
    isDEMOENV: ENV == 'DEMO',
    page_info: page_info,
    version: version,
    dom: dom
  }
})();

export default config;


// WEBPACK FOOTER //
// ./src/config.js
